.class public Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;
.super Landroid/view/View;
.source "AndroidCanvasUI.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lorg/microemu/android/device/ui/AndroidCanvasUI;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x1
    name = "CanvasView"
.end annotation


# instance fields
.field private FIRST_DRAG_SENSITIVITY_X:I

.field private FIRST_DRAG_SENSITIVITY_Y:I

.field pressedX:I

.field pressedY:I

.field final synthetic this$0:Lorg/microemu/android/device/ui/AndroidCanvasUI;


# direct methods
.method public constructor <init>(Lorg/microemu/android/device/ui/AndroidCanvasUI;Landroid/content/Context;)V
    .locals 2
    .parameter
    .parameter "context"

    .prologue
    const/4 v0, 0x5

    const/4 v1, 0x1

    .line 77
    iput-object p1, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->this$0:Lorg/microemu/android/device/ui/AndroidCanvasUI;

    .line 78
    invoke-direct {p0, p2}, Landroid/view/View;-><init>(Landroid/content/Context;)V

    .line 70
    iput v0, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->FIRST_DRAG_SENSITIVITY_X:I

    .line 71
    iput v0, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->FIRST_DRAG_SENSITIVITY_Y:I

    .line 73
    iget v0, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->FIRST_DRAG_SENSITIVITY_X:I

    neg-int v0, v0

    iput v0, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->pressedX:I

    .line 75
    iget v0, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->FIRST_DRAG_SENSITIVITY_Y:I

    neg-int v0, v0

    iput v0, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->pressedY:I

    .line 80
    invoke-virtual {p0, v1}, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->setFocusable(Z)V

    .line 81
    invoke-virtual {p0, v1}, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->setFocusableInTouchMode(Z)V

    .line 82
    return-void
.end method

.method private ignoreKey(I)Z
    .locals 1
    .parameter "keyCode"

    .prologue
    .line 169
    sparse-switch p1, :sswitch_data_0

    .line 177
    const/4 v0, 0x0

    :goto_0
    return v0

    .line 175
    :sswitch_0
    const/4 v0, 0x1

    goto :goto_0

    .line 169
    nop

    :sswitch_data_0
    .sparse-switch
        0x4 -> :sswitch_0
        0x18 -> :sswitch_0
        0x19 -> :sswitch_0
        0x4f -> :sswitch_0
        0x52 -> :sswitch_0
    .end sparse-switch
.end method


# virtual methods
.method public getHandler()Landroid/os/Handler;
    .locals 1

    .prologue
    .line 165
    invoke-super {p0}, Landroid/view/View;->getHandler()Landroid/os/Handler;

    move-result-object v0

    return-object v0
.end method

.method protected onDraw(Landroid/graphics/Canvas;)V
    .locals 7
    .parameter "androidCanvas"

    .prologue
    .line 90
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v1

    .line 91
    .local v1, ma:Lorg/microemu/MIDletAccess;
    if-nez v1, :cond_0

    .line 98
    :goto_0
    return-void

    .line 94
    :cond_0
    new-instance v0, Lorg/microemu/android/device/AndroidDisplayGraphics;

    invoke-direct {v0, p1}, Lorg/microemu/android/device/AndroidDisplayGraphics;-><init>(Landroid/graphics/Canvas;)V

    .line 95
    .local v0, g:Ljavax/microedition/lcdui/Graphics;
    invoke-virtual {p1}, Landroid/graphics/Canvas;->getClipBounds()Landroid/graphics/Rect;

    move-result-object v2

    .line 96
    .local v2, r:Landroid/graphics/Rect;
    iget v3, v2, Landroid/graphics/Rect;->left:I

    iget v4, v2, Landroid/graphics/Rect;->top:I

    invoke-virtual {v2}, Landroid/graphics/Rect;->width()I

    move-result v5

    invoke-virtual {v2}, Landroid/graphics/Rect;->height()I

    move-result v6

    invoke-virtual {v0, v3, v4, v5, v6}, Ljavax/microedition/lcdui/Graphics;->clipRect(IIII)V

    .line 97
    invoke-virtual {v1}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v3

    invoke-interface {v3, v0}, Lorg/microemu/DisplayAccess;->paint(Ljavax/microedition/lcdui/Graphics;)V

    goto :goto_0
.end method

.method public onKeyDown(ILandroid/view/KeyEvent;)Z
    .locals 3
    .parameter "keyCode"
    .parameter "event"

    .prologue
    const/4 v2, 0x0

    .line 102
    invoke-static {}, Lorg/microemu/MIDletBridge;->getCurrentMIDlet()Ljavax/microedition/midlet/MIDlet;

    move-result-object v1

    if-nez v1, :cond_0

    move v1, v2

    .line 113
    .end local p0
    :goto_0
    return v1

    .line 106
    .restart local p0
    :cond_0
    invoke-direct {p0, p1}, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->ignoreKey(I)Z

    move-result v1

    if-eqz v1, :cond_1

    move v1, v2

    .line 107
    goto :goto_0

    .line 110
    :cond_1
    invoke-static {}, Lorg/microemu/device/DeviceFactory;->getDevice()Lorg/microemu/device/Device;

    move-result-object v0

    .line 111
    .local v0, device:Lorg/microemu/device/Device;
    invoke-interface {v0}, Lorg/microemu/device/Device;->getInputMethod()Lorg/microemu/device/InputMethod;

    move-result-object p0

    .end local p0
    check-cast p0, Lorg/microemu/android/device/AndroidInputMethod;

    invoke-virtual {p0, p2}, Lorg/microemu/android/device/AndroidInputMethod;->buttonPressed(Landroid/view/KeyEvent;)V

    .line 113
    const/4 v1, 0x1

    goto :goto_0
.end method

.method public onKeyUp(ILandroid/view/KeyEvent;)Z
    .locals 3
    .parameter "keyCode"
    .parameter "event"

    .prologue
    const/4 v2, 0x0

    .line 118
    invoke-static {}, Lorg/microemu/MIDletBridge;->getCurrentMIDlet()Ljavax/microedition/midlet/MIDlet;

    move-result-object v1

    if-nez v1, :cond_0

    move v1, v2

    .line 129
    .end local p0
    :goto_0
    return v1

    .line 122
    .restart local p0
    :cond_0
    invoke-direct {p0, p1}, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->ignoreKey(I)Z

    move-result v1

    if-eqz v1, :cond_1

    move v1, v2

    .line 123
    goto :goto_0

    .line 126
    :cond_1
    invoke-static {}, Lorg/microemu/device/DeviceFactory;->getDevice()Lorg/microemu/device/Device;

    move-result-object v0

    .line 127
    .local v0, device:Lorg/microemu/device/Device;
    invoke-interface {v0}, Lorg/microemu/device/Device;->getInputMethod()Lorg/microemu/device/InputMethod;

    move-result-object p0

    .end local p0
    check-cast p0, Lorg/microemu/android/device/AndroidInputMethod;

    invoke-virtual {p0, p2}, Lorg/microemu/android/device/AndroidInputMethod;->buttonReleased(Landroid/view/KeyEvent;)V

    .line 129
    const/4 v1, 0x1

    goto :goto_0
.end method

.method public onTouchEvent(Landroid/view/MotionEvent;)Z
    .locals 6
    .parameter "event"

    .prologue
    .line 134
    invoke-static {}, Lorg/microemu/device/DeviceFactory;->getDevice()Lorg/microemu/device/Device;

    move-result-object v0

    .line 135
    .local v0, device:Lorg/microemu/device/Device;
    invoke-interface {v0}, Lorg/microemu/device/Device;->getInputMethod()Lorg/microemu/device/InputMethod;

    move-result-object v1

    check-cast v1, Lorg/microemu/android/device/AndroidInputMethod;

    .line 136
    .local v1, inputMethod:Lorg/microemu/android/device/AndroidInputMethod;
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getX()F

    move-result v4

    float-to-int v2, v4

    .line 137
    .local v2, x:I
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getY()F

    move-result v4

    float-to-int v3, v4

    .line 138
    .local v3, y:I
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I

    move-result v4

    packed-switch v4, :pswitch_data_0

    .line 157
    const/4 v4, 0x0

    .line 160
    :goto_0
    return v4

    .line 140
    :pswitch_0
    invoke-virtual {v1, v2, v3}, Lorg/microemu/android/device/AndroidInputMethod;->pointerPressed(II)V

    .line 141
    iput v2, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->pressedX:I

    .line 142
    iput v3, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->pressedY:I

    .line 160
    :cond_0
    :goto_1
    const/4 v4, 0x1

    goto :goto_0

    .line 145
    :pswitch_1
    invoke-virtual {v1, v2, v3}, Lorg/microemu/android/device/AndroidInputMethod;->pointerReleased(II)V

    goto :goto_1

    .line 148
    :pswitch_2
    iget v4, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->pressedX:I

    iget v5, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->FIRST_DRAG_SENSITIVITY_X:I

    sub-int/2addr v4, v5

    if-le v2, v4, :cond_1

    iget v4, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->pressedX:I

    iget v5, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->FIRST_DRAG_SENSITIVITY_X:I

    add-int/2addr v4, v5

    if-ge v2, v4, :cond_1

    iget v4, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->pressedY:I

    iget v5, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->FIRST_DRAG_SENSITIVITY_Y:I

    sub-int/2addr v4, v5

    if-le v3, v4, :cond_1

    iget v4, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->pressedY:I

    iget v5, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->FIRST_DRAG_SENSITIVITY_Y:I

    add-int/2addr v4, v5

    if-lt v3, v4, :cond_0

    .line 151
    :cond_1
    iget v4, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->FIRST_DRAG_SENSITIVITY_X:I

    neg-int v4, v4

    iput v4, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->pressedX:I

    .line 152
    iget v4, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->FIRST_DRAG_SENSITIVITY_Y:I

    neg-int v4, v4

    iput v4, p0, Lorg/microemu/android/device/ui/AndroidCanvasUI$CanvasView;->pressedY:I

    .line 153
    invoke-virtual {v1, v2, v3}, Lorg/microemu/android/device/AndroidInputMethod;->pointerDragged(II)V

    goto :goto_1

    .line 138
    :pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
        :pswitch_1
        :pswitch_2
    .end packed-switch
.end method
